import request from "@/utils/request";
// 属性值对象类型
export interface AttrValueData {
  id?: number;
  valueName: string;
  attrId: number | undefined;
  isEdit?:boolean
}
// 属性值列表类型
export type AttrValueListData = AttrValueData[]
// 属性对象类型
export type AttrData = {
  id?: number,
  attrName: string,
  categoryId: number,
  categoryLevel: number,
  attrValueList:AttrValueListData
}
// 属性列表类型
export type AttrListData = AttrData[]

export default {
  // GET  /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
  // attrInfoList  根据选中的一级二级三级分类id获取平台属性列表
  attrInfoList(category1Id: number, category2Id: number, category3Id: number) {
    return request.get<any,AttrListData>(
      `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
    );
  },

  // DELETE /admin/product/deleteAttr/{attrId}
  // deleteAttr 删除attr的接口
  deleteAttr(attrId:number){
    return request.delete<any,null>(`/admin/product/deleteAttr/${attrId}`)
  },

  // POST /admin/product/saveAttrInfo
  // saveAttrInfo  增加或者修改attr的接口
  saveAttrInfo(attr:AttrData){
    return request.post<any,null>(`/admin/product/saveAttrInfo`,attr)
  }
};
